package com.ldg.crm.dao;

import com.ldg.crm.entity.CustomerEntity;
import com.ldg.crm.entity.CustomerEntityExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface CustomerDao {
    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=CustomerEntitySqlProvider.class, method="countByExample")
    long countByExample(CustomerEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @DeleteProvider(type=CustomerEntitySqlProvider.class, method="deleteByExample")
    int deleteByExample(CustomerEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Delete({
        "delete from tb_customer",
        "where cid = #{cid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer cid);

    /**
     *
     * @mbg.generated
     */
    @Insert({
        "insert into tb_customer (cid, uid, ",
        "name, country, address, ",
        "url, email, phone, ",
        "fax, other, industry, ",
        "annual_revenue, bank_of_deposit, ",
        "bank_account, create_time, ",
        "update_time, last_time)",
        "values (#{cid,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, ",
        "#{name,jdbcType=VARCHAR}, #{country,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, ",
        "#{url,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, ",
        "#{fax,jdbcType=VARCHAR}, #{other,jdbcType=VARCHAR}, #{industry,jdbcType=VARCHAR}, ",
        "#{annualRevenue,jdbcType=VARCHAR}, #{bankOfDeposit,jdbcType=VARCHAR}, ",
        "#{bankAccount,jdbcType=VARCHAR}, #{createTime,jdbcType=DATE}, ",
        "#{updateTime,jdbcType=DATE}, #{lastTime,jdbcType=DATE})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="cid", before=true, resultType=Integer.class)
    int insert(CustomerEntity record);

    /**
     *
     * @mbg.generated
     */
    @InsertProvider(type=CustomerEntitySqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="cid", before=true, resultType=Integer.class)
    int insertSelective(CustomerEntity record);

    /**
     *
     * @mbg.generated
     */
    @SelectProvider(type=CustomerEntitySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="cid", property="cid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="uid", property="uid", jdbcType=JdbcType.INTEGER),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="country", property="country", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="fax", property="fax", jdbcType=JdbcType.VARCHAR),
        @Result(column="other", property="other", jdbcType=JdbcType.VARCHAR),
        @Result(column="industry", property="industry", jdbcType=JdbcType.VARCHAR),
        @Result(column="annual_revenue", property="annualRevenue", jdbcType=JdbcType.VARCHAR),
        @Result(column="bank_of_deposit", property="bankOfDeposit", jdbcType=JdbcType.VARCHAR),
        @Result(column="bank_account", property="bankAccount", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.DATE),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.DATE),
        @Result(column="last_time", property="lastTime", jdbcType=JdbcType.DATE)
    })
    List<CustomerEntity> selectByExample(CustomerEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @Select({
        "select",
        "cid, uid, name, country, address, url, email, phone, fax, other, industry, annual_revenue, ",
        "bank_of_deposit, bank_account, create_time, update_time, last_time",
        "from tb_customer",
        "where cid = #{cid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="cid", property="cid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="uid", property="uid", jdbcType=JdbcType.INTEGER),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="country", property="country", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="fax", property="fax", jdbcType=JdbcType.VARCHAR),
        @Result(column="other", property="other", jdbcType=JdbcType.VARCHAR),
        @Result(column="industry", property="industry", jdbcType=JdbcType.VARCHAR),
        @Result(column="annual_revenue", property="annualRevenue", jdbcType=JdbcType.VARCHAR),
        @Result(column="bank_of_deposit", property="bankOfDeposit", jdbcType=JdbcType.VARCHAR),
        @Result(column="bank_account", property="bankAccount", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.DATE),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.DATE),
        @Result(column="last_time", property="lastTime", jdbcType=JdbcType.DATE)
    })
    CustomerEntity selectByPrimaryKey(Integer cid);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=CustomerEntitySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") CustomerEntity record, @Param("example") CustomerEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=CustomerEntitySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") CustomerEntity record, @Param("example") CustomerEntityExample example);

    /**
     *
     * @mbg.generated
     */
    @UpdateProvider(type=CustomerEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(CustomerEntity record);

    /**
     *
     * @mbg.generated
     */
    @Update({
        "update tb_customer",
        "set uid = #{uid,jdbcType=INTEGER},",
          "name = #{name,jdbcType=VARCHAR},",
          "country = #{country,jdbcType=VARCHAR},",
          "address = #{address,jdbcType=VARCHAR},",
          "url = #{url,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "phone = #{phone,jdbcType=VARCHAR},",
          "fax = #{fax,jdbcType=VARCHAR},",
          "other = #{other,jdbcType=VARCHAR},",
          "industry = #{industry,jdbcType=VARCHAR},",
          "annual_revenue = #{annualRevenue,jdbcType=VARCHAR},",
          "bank_of_deposit = #{bankOfDeposit,jdbcType=VARCHAR},",
          "bank_account = #{bankAccount,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=DATE},",
          "update_time = #{updateTime,jdbcType=DATE},",
          "last_time = #{lastTime,jdbcType=DATE}",
        "where cid = #{cid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CustomerEntity record);
}